// Copyright Epic Games, Inc. All Rights Reserved.

#include "FirstProgram.h"

#include "FMyStyle.h"
#include "MyEditor.h"
#include "RequiredProgramMainCPPInclude.h"
#include "SMyMultilineEditableText.h"

#include "Framework/Application/SlateApplication.h"
#include "StandaloneRenderer.h"
#include "Widgets/SWindow.h"

DEFINE_LOG_CATEGORY_STATIC(LogFirstProgram, Log, All);	

IMPLEMENT_APPLICATION(FirstProgram, "FirstProgram");

/**
 * WinMain, called when the application is started
 */
int WINAPI WinMain(_In_ HINSTANCE hInInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR, _In_ int nCmdShow)
{
	// start up the main loop
	GEngineLoop.PreInit(GetCommandLineW());

	// crank up a normal Slate application using the platform's standalone renderer
	FSlateApplication::InitializeAsStandaloneApplication(GetStandardStandaloneRenderer());

	FSlateApplication::InitHighDPI(true);

	// TSharedPtr<SMyCanvas> MyCanvas = SNew(SMyCanvas);
	//
	// // create window
	// TSharedPtr<SWindow> MainWindow = SNew(SWindow)
	// 	.ClientSize(FVector2d(1024, 768))
	// 	.Title(FText::FromString(TEXT("UE5.4 SlateUI 学习测试程序")))
	// 	[
	// 		MyCanvas.ToSharedRef()
	// 	];
	//
	// FSlateApplication::Get().AddWindow(MainWindow.ToSharedRef());
	
	// TSharedPtr<SMyLeafWidget> MyLeafWidget = SNew(SMyLeafWidget)
	// 	.StartPoint(FVector2D(0, 0))
	// 	.EndPoint(FVector2D(200, 200));
	//
	// TSharedPtr<SWindow> MainWindow = SNew(SWindow)
	// 	.ClientSize(FVector2d(1024, 768))
	// 	.Title(FText::FromString(TEXT("UE5.4 SlateUI 学习测试程序")))[
	// 		MyLeafWidget.ToSharedRef()
	// 	];
	//
	// FSlateApplication::Get().AddWindow(MainWindow.ToSharedRef());

	// FMyStyle::ResetToDefault();
	// TSharedPtr<SMyCompoundWidget> MyCompoundWidget = SNew(SMyCompoundWidget)
	// 	.HAlign(HAlign_Center)
	// 	.VAlign(VAlign_Bottom)[
	// 		SNew(SMyButton)
	// 			.Text(FText::FromString(TEXT("点我试试")))
	// 			.OnClicked_Lambda([](){
	// 				// 弹出一个对话框
	// 				TSharedPtr<SMyCustomDialog> MyDialog = SNew(SMyCustomDialog)
	// 				.Title(FText::FromString(TEXT("提示框")))
	// 				.Icon(FMyStyle::Get().GetBrush("TrashCan"))
	// 				.Content()[
	// 					SNew(STextBlock)
	// 						.Text(FText::FromString(TEXT("这是一条提示消息！")))
	// 				]
	// 				.Buttons({
	// 					SMyCustomDialog::FButton(FText::FromString(TEXT("知道了")))
	// 				});
	// 				MyDialog->ShowModal();
	// 				return FReply::Handled();
	// 			})
	// 	];
	//
	// TSharedPtr<SWindow> MainWindow = SNew(SWindow)
	// 	.ClientSize(FVector2d(1024, 768))
	// 	.Title(FText::FromString(TEXT("UE5.4 SlateUI 学习测试程序")))[
	// 		MyCompoundWidget.ToSharedRef()
	// 	];
	//
	// FSlateApplication::Get().AddWindow(MainWindow.ToSharedRef());
	
	MyEditor Me = MyEditor();

	// TSharedPtr<SMyMultilineEditableText> MyMultilineEditableText = SNew(SMyMultilineEditableText);
 //   
	// TSharedPtr<SWindow> MainWindow = SNew(SWindow)
	// .ClientSize(FVector2d(1024, 768))
	// .Title(FText::FromString(TEXT("UE5.4 SlateUI 学习测试程序")))[
 //   		MyMultilineEditableText.ToSharedRef()
	// ];
	//
	// FSlateApplication::Get().AddWindow(MainWindow.ToSharedRef());

	// loop while the server does the rest
	while (!IsEngineExitRequested()){
		BeginExitIfRequested();
		FSlateApplication::Get().PumpMessages();
		FSlateApplication::Get().Tick();
	}
	FSlateApplication::Shutdown();

	GEngineLoop.AppPreExit();
	GEngineLoop.AppExit();

	return 0;
}
